#include <iostream>
using namespace std;

#include <vector>
#include <algorithm>

void duplicateZeros(vector<int>& arr)
{
    int n = arr.size();
    vector<int> tmp(arr);

    for (int i = 0, j = 0; j < n; i++)
    {
        if (tmp[i] != 0)
        {
            arr[j++] = tmp[i];
        }
        else
        {
            if (j + 1 < n)
                arr[j] = arr[j + 1] = 0;
            else
                arr[j] = 0;

            j += 2;
        }
    }
}